import { axios } from './axios';
const baseURL = process.env.VUE_APP_API_BASE_URL;

//请求方式,在分装
export function postAction(url, params) {
    return axios({
        url,
        method: 'post',
        data: params
    })
}
export function getAction(url, params) {
    return axios({
        url: url,
        method: 'get',
        params: params,
    })
}

//下载方法
export function downFile(url, param,fileName) {
    return axios({
        url,
        data: param,
        method: 'post',
        responseType: 'blob'
    }).then(res => {
        let { data } = res;
        let url = window.URL.createObjectURL(new Blob([data]))
        let link = document.createElement('a')
        link.style.display = 'none'
        link.href = url
        link.setAttribute('download', fileName)
        document.body.appendChild(link)
        link.click()
        document.body.removeChild(link) //下载完成移除元素
        window.URL.revokeObjectURL(url) //释放掉blob对象
    })
}
